<html>
<head><meta charset="utf-8"><title>Question about MIR terminators · t-compiler/wg-mir-opt · Zulip Chat Archive</title></head>
<h2>Stream: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/index.html">t-compiler/wg-mir-opt</a></h2>
<h3>Topic: <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html">Question about MIR terminators</a></h3>

<hr>

<base href="https://rust-lang.zulipchat.com">

<head><link href="https://rust-lang.github.io/zulip_archive/style.css" rel="stylesheet"></head>

<a name="214166908"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214166908" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> vn-ki <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214166908">(Oct 22 2020 at 10:16)</a>:</h4>
<p>From the docs</p>
<blockquote>
<p>Terminators are different from statements because they can have more than one successor – that is, control may flow to different places. Function calls like the call to Vec::new are always terminators because of the possibility of unwinding, although in the case of Vec::new we are able to see that indeed unwinding is not possible, and hence we list only one successor block, bb2.</p>
</blockquote>
<p>Is every function call a terminator? i.e. can every function unwind?</p>



<a name="214169706"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214169706" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214169706">(Oct 22 2020 at 10:45)</a>:</h4>
<p>every function call is a terminator, but not all function calls unwind. If the <code>cleanup</code> field (<a href="https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/terminator/enum.TerminatorKind.html#variant.Call.field.cleanup">https://doc.rust-lang.org/nightly/nightly-rustc/rustc_middle/mir/terminator/enum.TerminatorKind.html#variant.Call.field.cleanup</a>) is <code>None</code>, the function is known to never unwind</p>



<a name="214173719"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214173719" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214173719">(Oct 22 2020 at 11:32)</a>:</h4>
<p>Doesn't that mean that no cleanups are necessary if it unwinds?</p>



<a name="214174754"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214174754" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> oli <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214174754">(Oct 22 2020 at 11:44)</a>:</h4>
<p>hmm... I thought it meant both? But my information is only from a discussion about unwinding/not-unwinding intrinsics</p>



<a name="214175188"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214175188" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214175188">(Oct 22 2020 at 11:49)</a>:</h4>
<p>AIUI <code>cleanup: None</code> is an implicit <code>Resume</code> for all terminators, but maybe there's an exception</p>



<a name="214175204"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214175204" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214175204">(Oct 22 2020 at 11:49)</a>:</h4>
<p>We should probably clarify the docs</p>



<a name="214175216"></a>
<h4><a href="https://rust-lang.zulipchat.com#narrow/stream/189540-t-compiler/wg-mir-opt/topic/Question%20about%20MIR%20terminators/near/214175216" class="zl"><img src="https://rust-lang.github.io/zulip_archive/assets/img/zulip.svg" alt="view this post on Zulip" style="width:20px;height:20px;"></a> Jonas Schievink  [he/him] <a href="https://rust-lang.github.io/zulip_archive/stream/189540-t-compiler/wg-mir-opt/topic/Question.20about.20MIR.20terminators.html#214175216">(Oct 22 2020 at 11:49)</a>:</h4>
<p>Because everyone keeps getting confused about this :D</p>



<hr><p>Last updated: Aug 07 2021 at 22:04 UTC</p>
</html>